package com.inossem.warehousestorage_inossem.request.query;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.query.QueryMaterielBean;
import com.inossem.warehousestorage_inossem.bean.query.QueryMaterielListRequestBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

/**
 * Created by leij on 2017/6/12.
 */

public class QueryMaterielListRequest extends Request {

//    private static final String WAREHOUSE_NUMBER = "warehouseNumber"; //仓库号
//
//    private static final String AREA_NUMBER = "areaNumber";//存储区号
//
//    private static final String MATERIEL_CODE = "materielCode";//物料编码
//
//    private static final String MATERIEL_DESCRIPTION = "materielDescription";//物料描述
//
//    private static final String POSITION_NUMBER = "positionNumber";//仓位编码

    public static String request(Context context, QueryMaterielListRequestBean paramsBean, GsonBeanListener gsonBeanListener) {
        String tag;
//        Map<String, String> params = new HashMap<>();
//        params.put(WAREHOUSE_NUMBER, warehouseNumber == null ? "" : warehouseNumber);
//        params.put(AREA_NUMBER, areaNumber == null ? "" : areaNumber);
//        params.put(MATERIEL_CODE, materielCode == null ? "" : materielCode);
//        params.put(MATERIEL_DESCRIPTION, materielDescription == null ? "" : materielDescription);
//        params.put(POSITION_NUMBER, positionNumber == null ? "" : positionNumber);

//        QueryMaterielListRequestBean paramsBean = new QueryMaterielListRequestBean();
//        paramsBean.setWarehouseNumber(warehouseNumber == null ? "" : warehouseNumber);
//        paramsBean.setAreaNumber(areaNumber == null ? "" : areaNumber);
//        paramsBean.setMaterielCode(materielCode == null ? "" : materielCode);
//        paramsBean.setMaterielDescription(materielDescription == null ? "" : materielDescription);
//        paramsBean.setPositionNumber(positionNumber == null ? "" : positionNumber);
        Gson gson = new Gson();
        String params = gson.toJson(paramsBean, paramsBean.getClass());
        String url = RequestManage.getUrl(context, RequestConstant.URL_QUERY_MATERIEL_LIST);
        tag = RequestManage.getHttpsPostWithLoading(context, url, params, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                QueryMaterielBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), QueryMaterielBean.class);
                excuteJsonBean(context, bean, bean.getCode(), bean.getMsg(), gsonBeanListener);
            }
        });
        return tag;
    }

}
